package com.da.javatest.leetCode;

/**
 * @author chenlida
 * @date 2019/1/17 20:06
 * @description
 */
public class Code345 {
    public static void main(String[] args) {
        new Code345().reverseVowels("hello");
    }

    private String str = "aeiouAEIOU";

    public String reverseVowels(String s) {
        char[] c = s.toCharArray();
        int start = 0, end = c.length - 1;
        boolean flag1 = false, flag2 = false;
        while (start <= end) {
            if (str.contains(c[start] + "")) {
                flag1 = true;
            } else {
                start++;
            }
            if (str.contains(c[end] + "")) {
                flag2 = true;
            } else {
                end--;
            }
            if (flag1 && flag2) {
                flag1 = false;
                flag2 = false;
                char temp = c[start];
                c[start] = c[end];
                c[end] = temp;
                start++;
                end--;
            }
        }
        return new String(c);
    }
}
